package uk.co.hs.util.context;

import java.util.Arrays;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import uk.co.hs.web.interceptor.ModuleAccessibilityInterceptor;

@Component
public class ContextHelper {

  @Resource
  private ApplicationContext mCtx;
  

  public String[] getActiveProfiles()
  {
    return mCtx.getEnvironment().getActiveProfiles();
  }

  public List<String> getActiveProfilesAsList()
  {
    return Arrays.asList(getActiveProfiles());
  }

  public boolean isCoreActive()
  {
    return isModuleActive(ModuleAccessibilityInterceptor.MODULE_CORE);
  }

  private boolean isModuleActive(String aModuleName)
  {
    if (getActiveProfilesAsList().contains(aModuleName))
    {
      return true;
    }
    return false;

  }

}
